﻿#include <iostream>
using namespace std;
int k = 4;
int p = 101;
int x[4] = { 1,2,3,4 };
int Gcd(int a, int p, int &x, int &y)
{
    if (p == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    else
    {
        int val = Gcd(p, a % p, x, y);
        int temp = x;
        x = y;
        y = temp - (a / p) * y;
        return val;
    }
}
int inverse(int fm)
{
    int x, y;
    int gcd = Gcd(fm, p, x, y);
    if (gcd != 1)
    {
        return -1;
    }
    else
    {
        return (x % p + p) % p;
    }
}
int LDate(int i)
{
    int fz = 1;int fm = 1;
    for (int j = 0; j < k; j++)
    {
        if (i != j)
        {
            fz = (fz * (0 - x[j])) % p;
            fm = (fm * (x[i] - x[j])) % p;
        }
    }
    fz = (fz % p + p) % p;
    fm = (fm % p + p) % p;
    int val = inverse(fm);
    return (fz * val %p + p) % p;
}
int main()
{
    int y[4];
    for (int i = 0; i < 4; i++)
    {
        cin >> y[i];
    }
    int d = 0;
    for (int i = 0; i < k; i++)
    {
        int ldata = LDate(i);
        int data = (y[i] * ldata) % p;
        d = (d + data) % p;
    }
    d = (d % p + p) % p;
    cout << d << endl;
    return 0;
}
unsigned int powMod(unsigned int a, unsigned int b, unsigned int n) {
    unsigned long long x = 1, y = a;
    {
        y = y % n;
        while (b > 0)
        {
            if (b % 2 == 0)
            {
                x = (x* y) % n;
            }
            b = b / 2;
            y = (y * y) % n;
        }
        return x;
    } 
}